package com.changhongit.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.changhongit.base.impl.BaseDaoImpl;
import com.changhongit.dao.OrderDao;
import com.changhongit.entity.Order;
import com.changhongit.returnentity.ReturnOrder;
import com.changhongit.returnentity.ServiceOrderNum;
import com.changhongit.returnentity.ServiceOrderNumMonth;
import com.changhongit.returnentity.ServiceOrderNumYear;
import com.changhongit.util.PageView;

@Repository("orderDao")
public class OrderDaoImpl extends BaseDaoImpl<Order> implements OrderDao {

	@Override
	public int findCountOrder() {
		return getSqlSession().selectOne("order.count");
	}

	@Override
	public void addOrder(Order order) {
		getSqlSession().insert("order.add", order);
	}

	@Override
	public List<ReturnOrder> query(PageView pageView, ReturnOrder returnOrder) {
		Map<Object, Object> map = new HashMap<Object, Object>();
		map.put("paging", pageView);
		map.put("t", returnOrder);
		return getSqlSession().selectList("order.query",map);
	}

	@Override
	public List<ServiceOrderNum> queryServiceOrderNum(PageView pageView,ReturnOrder returnOrder) {
		Map<Object, Object> map = new HashMap<Object, Object>();
		map.put("paging", pageView);
		map.put("t", returnOrder);
		return getSqlSession().selectList("order.queryServiceOrderNum",map);
	}

	@Override
	public List<ServiceOrderNumYear> queryServiceOrderNumYear(PageView pageView,ReturnOrder order) {
		Map<Object, Object> map = new HashMap<Object, Object>();
		map.put("paging", pageView);
		map.put("t", order);
		return getSqlSession().selectList("order.queryServiceOrderNumYear",map);
	}

	@Override
	public List<ServiceOrderNumYear> queryRevenueByYear(PageView pageView,ReturnOrder order) {
		Map<Object, Object> map = new HashMap<Object, Object>();
		map.put("paging", pageView);
		map.put("t", order);
		return getSqlSession().selectList("order.queryRevenueByYear",map);
	}

	@Override
	public List<ServiceOrderNumYear> queryServiceUserRevenueByYear(
			PageView pageView, ReturnOrder order) {
		Map<Object, Object> map = new HashMap<Object, Object>();
		map.put("paging", pageView);
		map.put("t", order);
		return getSqlSession().selectList("order.queryServiceUserRevenueByYear",map);
	}

	@Override
	public int queryUnReadOrder(ReturnOrder returnOrder) {
		return getSqlSession().selectOne("order.queryUnReadOrder",returnOrder);
	}

	@Override
	public List<ServiceOrderNumYear> queryServiceOrderNumMonth(
			PageView pageView, ReturnOrder order) {
		Map<Object, Object> map = new HashMap<Object, Object>();
		map.put("paging", pageView);
		map.put("t", order);
		return getSqlSession().selectList("order.queryServiceOrderNumMonth",map);
	}

	@Override
	public List<ServiceOrderNumYear> queryServiceOrderNumDay(PageView pageView,
			ReturnOrder order) {
		Map<Object, Object> map = new HashMap<Object, Object>();
		map.put("paging", pageView);
		map.put("t", order);
		return getSqlSession().selectList("order.queryServiceOrderNumDay",map);
	}

	@Override
	public List<ServiceOrderNumMonth> queryServiceOrderNumYMonth(
			PageView pageView, ReturnOrder order) {
		Map<Object, Object> map = new HashMap<Object, Object>();
		map.put("paging", pageView);
		map.put("t", order);
		return getSqlSession().selectList("order.queryServiceOrderNumYMonth",map);
	}

	@Override
	public List<ServiceOrderNumYear> queryServiceUserRevenueByMonth(
			PageView pageView, ReturnOrder order) {
		Map<Object, Object> map = new HashMap<Object, Object>();
		map.put("paging", pageView);
		map.put("t", order);
		return getSqlSession().selectList("order.queryServiceUserRevenueByMonth",map);
	}

	@Override
	public List<ServiceOrderNumYear> queryServiceUserRevenueByDay(
			PageView pageView, ReturnOrder order) {
		Map<Object, Object> map = new HashMap<Object, Object>();
		map.put("paging", pageView);
		map.put("t", order);
		return getSqlSession().selectList("order.queryServiceUserRevenueByDay",map);
	}

	@Override
	public List<ServiceOrderNumMonth> queryServiceUserRevenueByYMonth(
			PageView pageView, ReturnOrder order) {
		Map<Object, Object> map = new HashMap<Object, Object>();
		map.put("paging", pageView);
		map.put("t", order);
		return getSqlSession().selectList("order.queryServiceUserRevenueByYMonth",map);
	}

	@Override
	public List<ServiceOrderNumYear> queryRevenueByMonth(PageView pageView,
			ReturnOrder order) {
		Map<Object, Object> map = new HashMap<Object, Object>();
		map.put("paging", pageView);
		map.put("t", order);
		return getSqlSession().selectList("order.queryRevenueByMonth",map);
	}

	@Override
	public List<ServiceOrderNumYear> queryRevenueByDay(PageView pageView,
			ReturnOrder order) {
		Map<Object, Object> map = new HashMap<Object, Object>();
		map.put("paging", pageView);
		map.put("t", order);
		return getSqlSession().selectList("order.queryRevenueByDay",map);
	}

	@Override
	public List<ServiceOrderNumMonth> queryRevenueByYmonth(PageView pageView,
			ReturnOrder order) {
		Map<Object, Object> map = new HashMap<Object, Object>();
		map.put("paging", pageView);
		map.put("t", order);
		return getSqlSession().selectList("order.queryRevenueByYmonth",map);
	}

}
